package org.example.redpacket.handler;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常返回
 *
 * @author: hero生仔
 */
@RestControllerAdvice("org.example.redpacket.controller")
public class GlobalExceptionHandler {
    @ExceptionHandler(Throwable.class)
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public R globalExceptionHandler(Throwable throwable) {
        return R.fail(throwable.getMessage());
    }
}
